<template>
  <div class="box">
    <header class="header">


      <van-nav-bar title="我的订单" left-text="返回" left-arrow @click-left="$router.back()" />

    </header>
    <main class="content">
      <van-cell title="梧桐女士 18852031314" is-link label="江苏 南京 梧桐街道 7号院落" />
      <van-swipe-cell v-for="item in store.orderList ">
        <van-card :num="item.count" :price="item.price"  :title="item.title" class="goods-card" :thumb="item.image" />
      </van-swipe-cell>
    </main>
  </div>
  <footer>
    <van-submit-bar :price="store.totalPrice*100" button-text="立即支付" @submit="onSubmit" @click="ska" />
  </footer>
</template>

<script setup>
import { useCounterStore } from '@/stores/counter'
// 可以在组件中的任意位置访问 `store` 变量 ✨
const store = useCounterStore()
import request from '@/tool/request'
import shake from '@/tool/shake'
import { showToast } from 'vant';
const onSubmit=()=>{
  let obj={
    id:new Date().getTime(),
    title:'NO'+new Date().getTime(),
    price:store.totalPrice
  }
  request.get('/pay',{
    params:obj
  }).then(res=>{
    if(res.data.code==200){
      window.location.href=res.data.data
      showToast('支付宝支付'); 
    }
  })
}
const ska=()=>{
  shake(onSubmit)
}
</script>

<style lang="scss" scoped></style>